<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>部门树</title>
    <meta name="keywords" content="列表部门表">
    <meta name="description" content="列表部门表">
    <link rel="shortcut icon" href="/web/favicon.ico">
    <link href="/web/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/web/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- bootstrap-table 表格插件样式 -->
    <link href="/web/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=20210202" rel="stylesheet"/>
    <link href="/web/css/animate.min.css" rel="stylesheet"/>
    <link href="/web/css/style.css?v=20200903" rel="stylesheet"/>
    <link href="/web/andy/css/ry-ui.css?v=4.6.1" rel="stylesheet"/>
    <a id="scroll-up" href="javascript:void(0);" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>
    <script src="/web/js/jquery.min.js"></script>
    <script src="/web/js/bootstrap.min.js"></script>
    <!-- bootstrap-table 表格插件 -->
    <script src="/web/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/web/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20210202"></script>
    <script src="/web/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js"></script>
    <!-- jquery-validate 表单验证插件 -->
    <script src="/web/ajax/libs/validate/jquery.validate.min.js"></script>
    <script src="/web/ajax/libs/validate/messages_zh.min.js"></script>
    <script src="/web/ajax/libs/validate/jquery.validate.extend.js"></script>
    <!-- jquery-validate 表单树插件 -->
    <script src="/web/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
    <!-- 遮罩层 -->
    <script src="/web/ajax/libs/blockUI/jquery.blockUI.js"></script>
    <script src="/web/ajax/libs/iCheck/icheck.min.js"></script>
    <script src="/web/ajax/libs/layer/layer.min.js"></script>
    <script src="/web/ajax/libs/layui/layui.js"></script>
    <script src="/web/andy/js/common.js?v=4.6.1"></script>
    <script src="/web/andy/js/andy-ui.js?v=4.6.1"></script>
    <script src="/webjars/vue/2.6.14/vue.min.js"></script>
    <link href="/web/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css" rel="stylesheet"/>
    <script src="/web/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js"></script>

    <style>
        body{height:auto;font-family: "Microsoft YaHei";}
        button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
    </style>
<body class="hold-transition box box-main">
<div id="container">
<input id="treeId"   name="treeId"    type="hidden"/>
<input id="treeName" name="treeName"  type="hidden"/>
<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
    <label id="btnShow" title="显示搜索" style="display:none;">︾</label>
    <label id="btnHide" title="隐藏搜索">︽</label>
</div>
    <div class="treeSearchInput" id="search">
        <label for="keyword">关键字：</label><input type="text" class="empty" id="keyword" maxlength="50">
        <button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
    </div>
    <div class="treeExpandCollapse">
        <a href="#" onclick="$.tree.expand()">展开</a> /
        <a href="#" onclick="$.tree.collapse()">折叠</a>
    </div>
    <div id="tree" class="ztree treeselect"></div>
</div>
</div>
<link href="/web/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css" rel="stylesheet"/>
<script src="/web/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js"></script>
<script >
    $(function() {
        var url ='/system/menu/menuTreeData?roleId='+window.parent.roleId;
        var options = {
            url: url,
            expandLevel: 2,
            data1: {
                key: {
                    title: "menuName",
                    name:'menuName'// 节点数据保存节点提示信息的属性名称
                },
                simpleData: {
                    enable: true,           // true / false 分别表示 使用 / 不使用 简单数据模式
                    idKey:'menuId',
                    pIdKey:'parentId'
                }
            },
            check:{
                enable: true
            },
            onClick : zOnClick
        };
        $.tree.init(options);
    });

    let vm = new Vue({
        el:'container'
    })
    function zOnClick(event, treeId, treeNode) {
        var treeId = treeNode.id;
        var treeName = treeNode.name;
        parent.changeDept(treeId,treeName);
        parent.close2();
    }
    function save() {
        let data = tree.getCheckedNodes(true);
        let ids=new Array();
        for(let i=0;i<data.length;i++){
            ids.push(data[i].menuId);
        }
        let roleId =window.parent.roleId;
        $.operate.postNotJsonParam('/system/menu/saveRoleMenus',{roleId:roleId,ids:ids},function(ret){
        });
    }
</script>
</body>
</html>